//
//  NRWCarSubscriptionHeaderCell.m
//  New_Runway
//
//  Created by NewLife on 2018/3/16.
//  Copyright © 2018年 NelsonJ. All rights reserved.
//

#import "NRWCarSubscriptionHeaderCell.h"

@implementation NRWCarSubscriptionHeaderCell
{
    UILabel *titleLabel;
    UIImageView *arrowImageView;
    UIView *lineView;
}

- (void)setTitleStr:(NSString *)titleStr {
    
    _titleStr = titleStr;
    
    titleLabel.text = titleStr;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        titleLabel = DPLabel()
        .setTextColor(getColorFromString(@"323232"))
        .setFont(kPingFangRegular13());
        
        arrowImageView = DPImageView()
        .setImage(getImageFromName(@"Right"));
        
        lineView = DPView().setBackgroundColor(getColorFromString(@"e1e1e1"));
        
        self
        .addSubview(titleLabel)
        .addSubview(arrowImageView)
        .addSubview(lineView);
        
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.mas_top);
            make.left.right.equalTo(self);
            make.height.equalTo(@(0.5));
        }];
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.equalTo(self);
            make.left.equalTo(self).offset(15.5);
        }];
        
        [arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.mas_right).offset(-17);
            make.centerY.equalTo(self.mas_centerY);
        }];
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewDidClick:)];
        [self addGestureRecognizer:tap];
        
    }
    return self;
}

- (void)viewDidClick:(UITapGestureRecognizer *)sender {
 
    if ([self.delegate respondsToSelector:@selector(subscriptionHeaderCell:didClickWithTitle:)]) {
        
        [self.delegate subscriptionHeaderCell:self didClickWithTitle:self.titleStr];
    }
}

@end
